Imports System.Data.SqlClient
Imports CommunityServer.WebServices.Membership
Imports CommunityServer.Membership
Imports Secure.Functions
Imports NENAData.DLC
Imports NENAData.NENAMember

Public Class AdminUpdateMemberDemographics
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents lbl1 As System.Web.UI.WebControls.Label
    Protected WithEvents Label1 As System.Web.UI.WebControls.Label
    Protected WithEvents ddlLoadMember As System.Web.UI.WebControls.DropDownList
    Protected WithEvents btnLoadDemographics As System.Web.UI.WebControls.Button
    Protected WithEvents chkENCCCertified As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkPCTASProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkPCTASInstructor As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkPCTASTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkPCTASDirector As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkENPCProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkENPCInstructor As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkENPCTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkENPCDirector As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCATNProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCATNInstructor As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCATNTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCATNDirector As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkTNCCProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkTNCCInstructor As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkTNCCTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkTNCCDirector As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEmployeeAdministration As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEmployeeClinical As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEmployeeEducator As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkEmployeeResearch As System.Web.UI.WebControls.CheckBox
    Protected WithEvents PersonalFirstName As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalLastName As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalAddress1 As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalAddress2 As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalCity As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalPostalCode As System.Web.UI.WebControls.TextBox
    Protected WithEvents lblOtherCountry As System.Web.UI.WebControls.Label
    Protected WithEvents txtOtherCountry As System.Web.UI.WebControls.TextBox
    Protected WithEvents lblAffiliate As System.Web.UI.WebControls.Label
    Protected WithEvents ddlAffiliate As System.Web.UI.WebControls.DropDownList
    Protected WithEvents txtWorkPhone As System.Web.UI.WebControls.TextBox
    Protected WithEvents txtMemberID As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnCancel As System.Web.UI.WebControls.Button
    Protected WithEvents btnSave As System.Web.UI.WebControls.Button
    Protected WithEvents PersonalEmail As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalHomePhone As System.Web.UI.WebControls.TextBox
    Protected WithEvents PersonalProvince As System.Web.UI.WebControls.TextBox
    Protected WithEvents btnDelete As System.Web.UI.WebControls.Button
    Protected WithEvents Label3 As System.Web.UI.WebControls.Label
    Protected WithEvents txtNurseLicense As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label2 As System.Web.UI.WebControls.Label
    Protected WithEvents Label5 As System.Web.UI.WebControls.Label
    Protected WithEvents txtENPCID As System.Web.UI.WebControls.TextBox
    Protected WithEvents Label4 As System.Web.UI.WebControls.Label
    Protected WithEvents txtTNCCID As System.Web.UI.WebControls.TextBox
    Protected WithEvents BtnReturn As System.Web.UI.WebControls.Button
    Protected WithEvents Label6 As System.Web.UI.WebControls.Label
    Protected WithEvents lblAcctStatusID As System.Web.UI.WebControls.Label
    Protected WithEvents lblAcctStatus As System.Web.UI.WebControls.Label
    Protected WithEvents txtPaymentDate As System.Web.UI.WebControls.TextBox
    Protected WithEvents ddl_ENAODistricts As System.Web.UI.WebControls.DropDownList
    Protected WithEvents lbl_ENAODistricts As System.Web.UI.WebControls.Label
    Protected WithEvents chkACTASProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkACTASInstructor As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkACTASTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkACTASDirector As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCCTASTrainer As System.Web.UI.WebControls.CheckBox
    Protected WithEvents chkCCTASProvider As System.Web.UI.WebControls.CheckBox
    Protected WithEvents txtEmployer As System.Web.UI.WebControls.TextBox
    Protected WithEvents check_RNAO As System.Web.UI.WebControls.CheckBox

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'only allow Moderators or Admins to view

        Dim oRoles As List(Of TelligentCommunity.Roles) = Session("Roles")

        If Not oRoles.Contains(TelligentCommunity.Roles.MembershipAdministrator) Then
            Response.Redirect("")
        End If

        If Not IsPostBack Then
            Load_ENAODistricts_DDL()
            BindMemberDDL()
            BindAffiliateDDL()
        End If

        If ddlAffiliate.SelectedValue.ToString = "5" Then
            lbl_ENAODistricts.Visible = True
            ddl_ENAODistricts.Visible = True
            check_RNAO.Visible = True
        Else
            lbl_ENAODistricts.Visible = False
            ddl_ENAODistricts.Visible = False
            check_RNAO.Visible = False
        End If

    End Sub

    Private Sub Load_ENAODistricts_DDL()

        Dim x As ENAODistricts = New ENAODistricts

        ddl_ENAODistricts.DataSource = x.GetDistricts_All()
        ddl_ENAODistricts.DataValueField = "District_ID"
        ddl_ENAODistricts.DataTextField = "District_Description" '"Province_ID"
        ddl_ENAODistricts.DataBind()
        ddl_ENAODistricts.Items.Insert(0, "--Select--")
    End Sub

    Private Sub BindAffiliateDDL()

        Dim conPubs As SqlConnection
        Dim cmdSelect As SqlCommand
        Dim dtrTitles As SqlDataReader
        Dim strSql As String

        strSql = "select Affiliate_ID, province from affiliate"

        conPubs = New SqlConnection(ConfigurationManager.AppSettings.Item("SQLConnectionString"))
        cmdSelect = New SqlCommand(strSql, conPubs)
        conPubs.Open()
        dtrTitles = cmdSelect.ExecuteReader()

        'populate the affiliate ddl
        ddlAffiliate.DataSource = dtrTitles
        ddlAffiliate.DataTextField = "Province"
        ddlAffiliate.DataValueField = "Affiliate_ID"
        ddlAffiliate.DataBind()

        dtrTitles.Close()
        conPubs.Close()
    End Sub

    Private Sub BindMemberDDL()
        Dim conPubs As SqlConnection
        Dim cmdSelect As SqlCommand
        Dim dtrTitles As SqlDataReader
        Dim strSql As String

        'strSql = "select * from members, affiliate where " & _
        '"members.affiliate_id = affiliate.affiliate_id " & _
        '"Account_Status > '" & ConfigurationManager.AppSettings.Item("Account_Status_Inactive") & "' " & _
        '"order by lastName ;"

        'join firstname and lastname in the same field
        strSql = "select lastname + ', ' + firstname as fullname, member_id from members " & _
        "order by lastName ;"
        '"WHERE Account_Status > '" & ConfigurationManager.AppSettings.Item("MemberStatusExpired") & "' " & _


        conPubs = New SqlConnection(ConfigurationManager.AppSettings.Item("SQLConnectionString"))
        cmdSelect = New SqlCommand(strSql, conPubs)
        conPubs.Open()
        dtrTitles = cmdSelect.ExecuteReader()

        ddlLoadMember.DataSource = dtrTitles
        ddlLoadMember.DataTextField = ("FullName")
        ddlLoadMember.DataValueField = ("member_id")
        ddlLoadMember.DataBind()

        dtrTitles.Close()
        conPubs.Close()
    End Sub

    Private Sub BindMemberData()
        Dim conPubs As SqlConnection
        Dim cmdSelect As SqlCommand
        Dim dtrTitles As SqlDataReader
        Dim strSql, strMemberID As String

        strMemberID = ddlLoadMember.SelectedValue.ToString

        strSql = "select * from members, affiliate where " & _
       "members.affiliate_id = affiliate.affiliate_id " & _
       " and members.member_id =" & strMemberID

        conPubs = New SqlConnection(ConfigurationManager.AppSettings.Item("SQLConnectionString"))
        cmdSelect = New SqlCommand(strSql, conPubs)
        conPubs.Open()
        dtrTitles = cmdSelect.ExecuteReader()

        While dtrTitles.Read
            PersonalFirstName.Text = dtrTitles("FirstName")
            PersonalLastName.Text = dtrTitles("LastName")
            PersonalEmail.Text = dtrTitles("emailaddress")
            PersonalHomePhone.Text = dtrTitles("homephone")
            PersonalAddress1.Text = dtrTitles("address")
            PersonalAddress2.Text = dtrTitles("address2")
            PersonalCity.Text = dtrTitles("city")
            PersonalPostalCode.Text = dtrTitles("postalcode")
            PersonalProvince.Text = dtrTitles("province")
            txtOtherCountry.Text = dtrTitles("country")
            txtWorkPhone.Text = dtrTitles("workphone")

            chkENPCProvider.Checked = ReturnChecked(dtrTitles("enpc_provider"))
            chkENPCInstructor.Checked = ReturnChecked(dtrTitles("enpc_instructor"))
            chkENPCTrainer.Checked = ReturnChecked(dtrTitles("enpc_course_trainer"))
            chkENPCDirector.Checked = ReturnChecked(dtrTitles("enpc_course_director"))
            txtENPCID.Text = dtrTitles("enpc_trainer_id")

            chkPCTASProvider.Checked = ReturnChecked(dtrTitles("pctas_provider"))
            chkPCTASInstructor.Checked = ReturnChecked(dtrTitles("pctas_instructor"))
            chkPCTASTrainer.Checked = ReturnChecked(dtrTitles("pctas_course_trainer"))
            chkPCTASDirector.Checked = ReturnChecked(dtrTitles("pctas_course_director"))

            chkACTASProvider.Checked = ReturnChecked(dtrTitles("actas_provider"))
            chkACTASInstructor.Checked = ReturnChecked(dtrTitles("actas_instructor"))
            chkACTASTrainer.Checked = ReturnChecked(dtrTitles("actas_course_trainer"))
            chkACTASDirector.Checked = ReturnChecked(dtrTitles("actas_course_director"))

            chkCCTASTrainer.Checked = ReturnChecked(dtrTitles("cctas_trainer"))
            chkCCTASProvider.Checked = ReturnChecked(dtrTitles("cctas_provider"))

            chkCATNProvider.Checked = ReturnChecked(dtrTitles("catn_provider"))
            chkCATNInstructor.Checked = ReturnChecked(dtrTitles("catn_instructor"))
            chkCATNTrainer.Checked = ReturnChecked(dtrTitles("catn_course_trainer"))
            chkCATNDirector.Checked = ReturnChecked(dtrTitles("catn_course_director"))

            chkTNCCProvider.Checked = ReturnChecked(dtrTitles("tncc_provider"))
            chkTNCCInstructor.Checked = ReturnChecked(dtrTitles("tncc_instructor"))
            chkTNCCTrainer.Checked = ReturnChecked(dtrTitles("tncc_course_trainer"))
            chkTNCCDirector.Checked = ReturnChecked(dtrTitles("tncc_course_director"))
            txtTNCCID.Text = dtrTitles("tncc_trainer_id")

            chkENCCCertified.Checked = ReturnChecked(dtrTitles("encc_certified"))
            chkEmployeeAdministration.Checked = ReturnChecked(dtrTitles("aoe_administration"))
            chkEmployeeClinical.Checked = ReturnChecked(dtrTitles("aoe_clinical"))
            chkEmployeeEducator.Checked = ReturnChecked(dtrTitles("aoe_educator"))
            chkEmployeeResearch.Checked = ReturnChecked(dtrTitles("aoe_research"))
            check_RNAO.Checked = ReturnChecked(dtrTitles("RNAO"))

            txtMemberID.Text = dtrTitles("member_id")
            txtNurseLicense.Text = dtrTitles("Nurses_License_ID")
            txtEmployer.Text = dtrTitles("Employer")

            'set SetAffiliateDDLIndex()
            ddlAffiliate.SelectedIndex = CType(dtrTitles("affiliate_id"), Integer)

            'lblAcctPaid.Text() = dtrTitles("Paid")
            txtPaymentDate.Text = dtrTitles("Date_Paid")
            lblAcctStatusID.Text = ReturnStatus(dtrTitles("Account_Status"))

            ddl_ENAODistricts.SelectedIndex = dtrTitles("ENAODistrict_ID")
        End While

        dtrTitles.Close()
        conPubs.Close()

    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        If User.IsInRole(ConfigurationManager.AppSettings.Item("RoleNoSave")) Then
            Response.Redirect("")
        End If

        Dim strFirstName, strLastName, strEmail, strHomePhone As String
        Dim strAddress1, strAddress2, strCity, strPostalCode As String
        Dim strAffiliateId As String
        Dim strProvince, strCountry, strWorkPhone As String
        Dim strAdministration, strClinical, strEducator, strResearch As String
        Dim strPCTASProvider, strPCTASInstructor, strPCTASTrainer, strPCTASDirector As String
        Dim strACTASProvider, strACTASInstructor, strACTASTrainer, strACTASDirector As String
        Dim strCCTASProvider, strCCTASTrainer As String
        Dim strENPCProvider, strENPCInstructor, strENPCTrainer, strENPCDirector As String
        Dim strCATNProvider, strCATNInstructor, strCATNTrainer, strCATNDirector As String
        Dim strTNCCProvider, strTNCCInstructor, strTNCCTrainer, strTNCCDirector As String
        Dim strSQL, strENCCCertified, strNursesLicenseID As String
        Dim strENPCID, strTNCCID, strEmployer, strRNAO As String
        Dim intAffiliate As Integer

        If txtMemberID.Text = "0" Then
            Exit Sub
        End If

        strENPCID = SqlReplaceText(txtENPCID.Text)
        strTNCCID = SqlReplaceText(txtTNCCID.Text)

        strFirstName = SqlReplaceText(PersonalFirstName.Text)
        strLastName = SqlReplaceText(PersonalLastName.Text)
        strEmail = SqlReplaceText(PersonalEmail.Text)
        strHomePhone = SqlReplaceText(PersonalHomePhone.Text)
        strAddress1 = SqlReplaceText(PersonalAddress1.Text)
        strAddress2 = SqlReplaceText(PersonalAddress2.Text)
        strCity = SqlReplaceText(PersonalCity.Text)
        strPostalCode = SqlReplaceText(PersonalPostalCode.Text)
        strAffiliateId = ddlAffiliate.SelectedValue.ToString
        strProvince = SqlReplaceText(PersonalProvince.Text)
        strCountry = SqlReplaceText(txtOtherCountry.Text)
        strWorkPhone = SqlReplaceText(txtWorkPhone.Text)

        strAdministration = EvaluateChecked(chkEmployeeAdministration.Checked)
        strClinical = EvaluateChecked(chkEmployeeClinical.Checked)
        strEducator = EvaluateChecked(chkEmployeeEducator.Checked)
        strResearch = EvaluateChecked(chkEmployeeResearch.Checked)

        strENCCCertified = EvaluateChecked(chkENCCCertified.Checked)

        strPCTASProvider = EvaluateChecked(chkPCTASProvider.Checked)
        strPCTASInstructor = EvaluateChecked(chkPCTASInstructor.Checked)
        strPCTASTrainer = EvaluateChecked(chkPCTASTrainer.Checked)
        strPCTASDirector = EvaluateChecked(chkPCTASDirector.Checked)

        strACTASProvider = EvaluateChecked(chkACTASProvider.Checked)
        strACTASInstructor = EvaluateChecked(chkACTASInstructor.Checked)
        strACTASTrainer = EvaluateChecked(chkACTASTrainer.Checked)
        strACTASDirector = EvaluateChecked(chkACTASDirector.Checked)

        strCCTASProvider = EvaluateChecked(chkCCTASProvider.Checked)
        strCCTASTrainer = EvaluateChecked(chkACTASTrainer.Checked)

        strENPCProvider = EvaluateChecked(chkENPCProvider.Checked)
        strENPCInstructor = EvaluateChecked(chkENPCInstructor.Checked)
        strENPCTrainer = EvaluateChecked(chkENPCTrainer.Checked)
        strENPCDirector = EvaluateChecked(chkENPCDirector.Checked)

        strCATNProvider = EvaluateChecked(chkCATNProvider.Checked)
        strCATNInstructor = EvaluateChecked(chkCATNInstructor.Checked)
        strCATNTrainer = EvaluateChecked(chkCATNTrainer.Checked)
        strCATNDirector = EvaluateChecked(chkCATNDirector.Checked)

        strTNCCProvider = EvaluateChecked(chkTNCCProvider.Checked)
        strTNCCInstructor = EvaluateChecked(chkTNCCInstructor.Checked)
        strTNCCTrainer = EvaluateChecked(chkTNCCTrainer.Checked)
        strTNCCDirector = EvaluateChecked(chkTNCCDirector.Checked)

        strRNAO = EvaluateChecked(check_RNAO.Checked)

        strNursesLicenseID = txtNurseLicense.Text
        strEmployer = SqlReplaceText(txtEmployer.Text)

        'add 1 since ddl's start with 0
        intAffiliate = ddlAffiliate.SelectedIndex

        strSQL = "update members set " & _
            "lastname = '" & strLastName & "', " & _
            "firstname = '" & strFirstName & "', " & _
            "address = '" & strAddress1 & "', " & _
            "address2 = '" & strAddress2 & "', " & _
            "city = '" & strCity & "', " & _
            "postalcode = '" & strPostalCode & "', " & _
            "province = '" & strProvince & "', " & _
            "country = '" & strCountry & "', " & _
            "affiliate_ID = '" & intAffiliate & "', "
        strSQL &= "homephone = '" & strHomePhone & "', " & _
            "workphone = '" & strWorkPhone & "', " & _
            "emailaddress = '" & strEmail & "', " & _
            "aoe_Administration = '" & strAdministration & "', " & _
            "aoe_clinical = '" & strClinical & "', " & _
            "aoe_educator = '" & strEducator & "', " & _
            "aoe_research = '" & strResearch & "', " & _
            "ENCC_Certified = '" & strENCCCertified & "', "
        strSQL &= "tncc_provider = '" & strTNCCProvider & "', " & _
            "tncc_instructor = '" & strTNCCInstructor & "', " & _
            "tncc_course_trainer = '" & strTNCCTrainer & "', " & _
            "tncc_course_director = '" & strTNCCDirector & "', " & _
            "enpc_provider = '" & strENPCProvider & "', " & _
            "enpc_instructor = '" & strENPCInstructor & "', " & _
            "enpc_course_trainer = '" & strENPCTrainer & "', " & _
            "enpc_course_director = '" & strENPCDirector & "', " & _
            "catn_provider = '" & strCATNProvider & "', " & _
            "catn_instructor = '" & strCATNInstructor & "', " & _
            "catn_course_trainer = '" & strCATNTrainer & "', " & _
            "catn_course_director = '" & strCATNDirector & "', "
        strSQL &= "pctas_provider = '" & strPCTASProvider & "', " & _
            "pctas_instructor = '" & strPCTASInstructor & "', " & _
            "pctas_course_trainer = '" & strPCTASTrainer & "', " & _
            "pctas_course_director = '" & strPCTASDirector & "', "
        strSQL &= "actas_provider = '" & strACTASProvider & "', " & _
            "actas_instructor = '" & strACTASInstructor & "', " & _
            "actas_course_trainer = '" & strACTASTrainer & "', " & _
            "actas_course_director = '" & strACTASDirector & "', " & _
            "cctas_provider = '" & strCCTASProvider & "', " & _
            "cctas_trainer = '" & strCCTASTrainer & "', "
        strSQL &= "nurses_license_id = '" & strNursesLicenseID & "', " & _
            "enpc_trainer_id = '" & strENPCID & "', " & _
            "tncc_trainer_id = '" & strTNCCID & "', " & _
            "rnao = '" & strRNAO & "', " & _
            "employer = '" & strEmployer & "' " & _
            "where member_id =" & txtMemberID.Text & ";"

        'Response.Write("strSQL: " & strSQL)

        Dim conPubs As SqlConnection
        Dim cmdSelect As SqlCommand

        conPubs = New SqlConnection(ConfigurationManager.AppSettings.Item("SQLConnectionString"))
        cmdSelect = New SqlCommand(strSQL, conPubs)
        conPubs.Open()
        cmdSelect.ExecuteNonQuery()
        conPubs.Close()

        BindMemberData()

    End Sub

    Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        'check for a loaded account
        If txtMemberID.Text = "0" Then
            Exit Sub
        End If

        If User.IsInRole(ConfigurationManager.AppSettings.Item("RoleNoSave")) Then
            Response.Redirect("default.aspx")
        End If

        'set the user account inactive
        Dim strSql As String
        Dim conPubs As SqlConnection
        Dim cmdSelect As SqlCommand

        strSql = "update members set " & _
            "Account_Status = '" & ConfigurationManager.AppSettings.Item("MemberStatusExpired") & "' " & _
            "where member_id =" & txtMemberID.Text & ";"

        conPubs = New SqlConnection(ConfigurationManager.AppSettings.Item("SQLConnectionString"))
        cmdSelect = New SqlCommand(strSql, conPubs)
        conPubs.Open()
        cmdSelect.ExecuteNonQuery()
        conPubs.Close()

        BindMemberDDL()
        Response.Redirect(Request.RawUrl)

        'BindMemberData()

    End Sub

    Private Function EvaluateChecked(ByVal strChecked) As String

        If strChecked = "false" Then
            Return ("N")
        Else
            Return ("Y")
        End If

    End Function

    Private Function ReturnChecked(ByVal strChecked) As Boolean

        If strChecked = "Y" Then
            Return True
        Else
            Return False
        End If

    End Function
    Private Sub btnLoadDemographics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadDemographics.Click
        BindMemberData()
        'activate the save and delete buttons
        btnSave.Enabled = True
        btnDelete.Enabled = True
        ddlAffiliate.Enabled = True

    End Sub

    Function SqlReplaceText(ByVal strSql As String) As String
        Dim strFixedSQL As String

        strFixedSQL = Replace(strSql, "'", "")
        strFixedSQL = Replace(strFixedSQL, "[", "")
        strFixedSQL = Replace(strFixedSQL, "%", "")
        'strFixedSQL = Replace(strFixedSQL, "_", "[_]") 
        'some people may have underscores in their lastname
        strFixedSQL = Replace(strFixedSQL, "--", "")

        'return the fixed sql
        SqlReplaceText = strFixedSQL
    End Function

    Private Sub BtnReturn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnReturn.Click
        Response.Redirect("")
    End Sub

End Class
